package com.ruoyi.recycleshop.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.recycle.vo.MultiExchangeVO;
import com.ruoyi.recycleshop.service.CashRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wallet")
@Api(tags = "我的钱包")
public class WalletController extends BaseController {
    @Autowired
    private CashRegisterService cashRegisterService;


    @GetMapping("/exchangeRecord")
    @ApiOperation("积分明细和提现记录")
    @ApiImplicitParam(name = "shopId", value = "门店ID")
    public R<Map<String, List<MultiExchangeVO>>> exchangeRecord(@RequestParam Long shopId) {
        return R.ok(cashRegisterService.exchangeRecord(shopId));
    }


    @GetMapping("/withdraw")
    @ApiOperation("提现")
    @ApiImplicitParams({@ApiImplicitParam(name = "account", value = "账号"), @ApiImplicitParam(name = "withdrawAmount", value = "提现积分")})
    public R<Boolean> withdraw(@RequestParam String account, @RequestParam Integer withdrawAmount) {
        return R.ok(cashRegisterService.withdraw(account, withdrawAmount));
    }

}
